home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 28 November 2000
- //
- // Description:
- // Builds a menu's and commands for the list of image planes
- // associated with the current camera.
- //
-
-
- //
- // Procedure Name:
- // getPanelCamera
- //
- // Description:
- // Get the camera shape name in the model panel.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // An empty string is returned if there is no camera.
- //
- proc string getPanelCamera( string $modelPanel )
- {
- string $cameraShapeName = "";
-
- if (`modelPanel -exists $modelPanel`) {
- string $camera = `modelPanel -q -camera $modelPanel`;
-
- if ($camera != "") {
- // Get current camera's shape
- string $cameraShapes[] = `listRelatives -shapes $camera`;
-
- if (size($cameraShapes) > 0) {
- $cameraShapeName = $cameraShapes[0];
- }
- }
-
- if ($cameraShapeName == "") {
- warning ($modelPanel+" does not have a valid camera");
- }
- }
- else {
- warning ($modelPanel+" is not a model panel");
- }
-
- return $cameraShapeName;
- }
-
-
- //
- // Procedure Name:
- // getImagePlaneList
- //
- // Description:
- // Create a list of image planes for the current camera view.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // Array of image plane names
- //
- proc string[] getImagePlaneList( string $modelPanel )
- {
- string $result[];
-
- string $cameraShape = `getPanelCamera $modelPanel`;
-
- if ($cameraShape != "") {
- $result = `listConnections ($cameraShape + ".imagePlane")`;
- }
-
- return $result;
- }
-
-
- //
- // Procedure Name:
- // createImportedImagePlane
- //
- // Description:
- // Creates an image plane with the file name provided.
- //
- // Input Arguments:
- // imageName : image file name from the browser
- // type : file type
- //
- // Return Value:
- // Returns 1 so that the file browser will close.
- //
- global proc int createImportedImagePlane (string $modelPanel,
- string $imageName,
- string $type)
- {
- // Check whether an image filename was provided
-
- if ( $imageName != "" ) {
- string $cameraShape = `getPanelCamera $modelPanel`;
-
- if ($cameraShape != "") {
- // create image plane
- string $newImagePlane = `shadingNode -asUtility imagePlane`;
-
- // set the image plane type to image file
- setAttr ($newImagePlane + ".type") 0;
-
- // assign the imageName to the imagePlane
- setAttr ($newImagePlane + ".imageName")
- -type "string" $imageName;
-
- cameraImagePlaneUpdate $cameraShape $newImagePlane;
- }
- }
-
- return 1;
- }
-
-
- //
- // Procedure Name:
- // importImagePlane
- //
- // Description:
- // Imports an image file as an image plane.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- global proc importImagePlane( string $modelPanel )
- {
- // Do we have a camera ?
-
- if (`getPanelCamera $modelPanel` != "") {
- // Set the current working directory to the project's
- // sourceimage directory
-
- string $workspace = `workspace -q -fullName`;
-
- setWorkingDirectory $workspace "image" "sourceImages";
-
- string $cmd = ("createImportedImagePlane " + $modelPanel);
-
- fileBrowser ($cmd, "Open", "image", 0);
- }
- }
-
-
- global proc buildImagePlaneList (string $parent, string $modelPanel)
-
- //
- // builds a menu list of image planes for the current camera
- //
-
- {
- setParent -m $parent;
-
- menu -e -deleteAllItems $parent;
-
- string $imagePlanes[] = `getImagePlaneList $modelPanel`;
-
- for ($imagePlane in $imagePlanes) {
- string $editCommand = "select " + $imagePlane +
- "; showEditor " + $imagePlane;
-
- menuItem -tearOff false
- -l $imagePlane
- -command $editCommand;
-
- }
-
- }
-
-
- //
- // Procedure Name:
- // buildImagePlaneMenu
- //
- // Description:
- // Builds a menu for managing image planes in the model pane's
- // view menu.
- //
- // Input Arguments:
- // parent : parent menu to build menu for.
- //
- // Return Value:
- // None.
- //
- global proc buildImagePlaneMenu (string $parent, string $modelPanel)
- {
- string $imagePlanes[] = `getImagePlaneList $modelPanel`;
-
- int $anyImagePlanes = size($imagePlanes) > 0;
-
- setParent -m $parent;
-
- menu -e -deleteAllItems $parent;
-
- menuItem -l "Import Image..."
- -c ("importImagePlane " + $modelPanel)
- importImageMenuItem;
-
- string $postCommand =
- ("buildImagePlaneList imagePlaneEditSubMenu " + $modelPanel);
-
- menuItem -l "Image Plane Attributes"
- -enable $anyImagePlanes
- -subMenu true
- -tearOff false
- -postMenuCommand $postCommand
- imagePlaneEditSubMenu;
-
- setParent -m ..; // from imagePlaneSubmenu
- }
-